package cn.kgm.template.server.controller;

import cn.kgm.core.http.request.BaseController;
import cn.kgm.core.jackson.JsonUtil;
import cn.kgm.template.server.entity.TemplateChecked;
import cn.kgm.template.server.service.TemplateCheckedService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * # 技术改变自己 #
 * 模板数据,select标签表选中数据
 * @author kapp-i
 * @date   2024-03-18 15:36:58
 */
@Slf4j
@SpringBootTest
class TemplateCheckedTestService extends BaseController {

    @Autowired
    private TemplateCheckedService templateCheckedService;

    @Test
    void page() {
        IPage<TemplateChecked> page = getPage();
        LambdaQueryWrapper<TemplateChecked> wrapper = Wrappers.lambdaQuery(TemplateChecked.builder()
                .build());
        IPage<TemplateChecked> pages = templateCheckedService.page(page, wrapper);
        log.info("TemplateCheckedTestService::page===>{}", JsonUtil.toJson(pages.getRecords()));
    }

    @Test
    void get() {
        Long id = 1L;
        TemplateChecked templateChecked =templateCheckedService.getById(id);
        log.info("TemplateCheckedTestService::get===>{}", JsonUtil.toJson(templateChecked));
    }

    @Test
    void save() {
        TemplateChecked templateChecked = TemplateChecked.builder()
                .build();
            templateCheckedService.save(templateChecked);
        log.info("TemplateCheckedTestService::save===>{}", JsonUtil.toJson(templateChecked));
    }

    @Test
    void update() {
        TemplateChecked templateChecked = TemplateChecked.builder()
                .build();
            templateCheckedService.updateById(templateChecked);
        log.info("TemplateCheckedTestService::update===>{}", JsonUtil.toJson(templateChecked));
    }

    @Test
    void delete() {
        Long[] ids = new Long[]{0L};
            templateCheckedService.update(Wrappers.<TemplateChecked>lambdaUpdate()
                .set(TemplateChecked::getIsDel, true)
                .in(TemplateChecked::getId, ids));
        log.info("TemplateCheckedTestService::delete===>{}", JsonUtil.toJson(ids));
    }
}
